<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>出行规划webAPI</title>
		<link rel="stylesheet" type="text/css" href="css/weui/base.css"/>
		<link rel="stylesheet" type="text/css" href="lib/weui.css"/>
		<link rel="stylesheet" type="text/css" href="css/weui/jquery-weui.css"/>
		<link rel="stylesheet" type="text/css" href="iconfont/iconfont.css"/>
	</head>
	<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=MMh4H9m5FLBpizlht86GnGynuaM0oGKz"></script>
	<body>
		<input type="text" id="suggestId_start" placeholder="输入起点" />
		<br />
		<input type="text" name="" id="suggestId_end" placeholder="输入终点" /><br />
		<a class="iconfont" id="research_btn" href="javascript:;">&#xe709;</a>
		
		<script src="js/jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$("#research_btn").click(function(){
				$.ajax({
					type: "post",
					url: "https://api.map.baidu.com/direction/v2/transit",
					data: {
						"origin": "driving",//"double,double"，格式为：纬度,经度，小数点后不超过6位，如：“40.056878,116.30815”
	
						"origin": $("#suggestId_start").val(),
						"destination": $("#suggestId_end").val(),
						"origin_region": "吉林",
						"destination_region": "吉林",
						"output": "json",
						"ak": "MMh4H9m5FLBpizlht86GnGynuaM0oGKz"
					},
					async: false,
					cache: false,
					dataType: "jsonp", //数据类型为jsonp
					success: function(data) {
						if(data.type == 1) {
							//当搜索无结果时
							$("#noResultCar").show();
							$("#carJumpToMap").hide();
						} else if(data.type == 2) {
							//当搜索有结果时
							$("#noResultCar").hide();
							$("#carJumpToMap").show();

						}
					},
					error: function(data) {
						$.alert("连接超时，请稍后再试", "提示");
					}
				});
			})
			
		</script>
	</body>
</html>
